// axios的请求

import request from '@/utlis/request.js'
// import store from '@/store/index.js'

// 用户登录的接口
export function loginAPI(data) {
  return request({
    method: 'POST',
    url: '/v1_0/authorizations',
    data
  })
}

//获得验证码的接口
export function getSmsAPI(params) {
  return request({
    url: `/v1_0/sms/codes/${params}`,
  })
}

// 获得用户的详细信息
export function getUserInfo() {
  return request({
    url: '/v1_0/user',
    // headers: {
    //   Authorization: `Bearer ${store.state.user.token}`
    // }
  })
}

// 用户的个人资料
export function getUserProfile() {
  return request({
    url: '/v1_0/user/profile',
  })
}

// 修改资料
export function modefyUserProfile(data) {
  return request({
    url: '/v1_0/user/profile',
    method: 'PATCH',
    data
  })
}


//获取用户的频道列表
export function getUserChannels() {
  return request({
    url: '/v1_0/user/channels',
  })
}

// 获取全部的频道列表

export function getAllChannels() {
  return request({
    url: '/v1_0/channels',
  })
}

export function updataUserChannel(channel) {
  return request({
    url: '/v1_0/user/channels',
    method: 'PATCH',
    data: {
      channels: [channel]
    }
  })
}


// 删除用户指定的频道
export function deleteUserChannel(channel) {
  return request({
    url: `/v1_0/user/channels/${channel}`,
    method: 'DELETE',
  })
}

//获取搜索的了联想记忆的内容
export function getSuggestionAPI(q) {
  return request({
    url: '/v1_0/suggestion',
    method: 'GET',
    params: {
      q   //q:q
    }
  })
}

//获取搜索建议
export function getSearchResult(params) {
  return request({
    url: '/v1_0/search',
    method: 'GET',
    params
  })
}

//关注用户
export function getFollow(target) {
  return request({
    url: '/v1_0/user/followings',
    method: 'POST',
    data: {
      target
    }
  })
}

//取消关注用户
export function deleteFollow(target) {
  return request({
    url: `/v1_0/user/followings/${target}`,
    method: 'DELETE',
  })
}

//更新用户的头像
export function updataUserAvator(data) {
  return request({
    url: '/v1_0/user/photo',
    method: 'PATCH',
    data
  })
}





